import { FormRule } from 'tdesign-vue-next';
import { ref } from 'vue';

import { EQUIPMENT_TYPE_OPTIONS, TRANSPORT_PROTOCAL_OPTIONS, VIDEOTYPE_OPTIONS } from '@/constants/data';

export const INIT_DATA = { name: '', type: '', model: '', serial: '', address: '' };

export const list = ref([
  { label: '设备名称', value: '', key: 'name', type: 'InputView', placeholder: '请输入设备名称', clearable: true },
  {
    label: '设备类型',
    value: true,
    key: 'type',
    type: 'SelectView',
    options: EQUIPMENT_TYPE_OPTIONS,
    placeholder: '请选择设备类型',
    clearable: true,
  },
  { label: '设备型号', value: '', key: 'model', type: 'InputView', placeholder: '请输入设备型号', clearable: true },
  {
    label: '设备序列号',
    value: '',
    key: 'serial',
    type: 'InputView',
    placeholder: '请输入设备序列号',
    clearable: true,
  },
  {
    label: '设备地址',
    value: {},
    key: 'address',
    type: 'AddressCascaderView',
    cascader: { placeholder: '请选择设备地址', clearable: true },
    input: { placeholder: '请填写设备详细地址', clearable: true },
  },
]);

export const video = ref([
  {
    label: '视频流类型',
    value: '',
    key: 'stream_typ',
    type: 'SelectView',
    options: VIDEOTYPE_OPTIONS,
    placeholder: '请输入视频流类型',
    clearable: true,
  },
  {
    label: '视频流地址',
    value: '',
    key: 'stream_url',
    type: 'InputView',
    placeholder: '请输入视频流地址',
    clearable: true,
  },
  { label: '用户名', value: '', key: 'stream_usr', type: 'InputView', placeholder: '请输入用户名', clearable: true },
  { label: '密码', value: '', key: 'stream_pwd', type: 'InputView', placeholder: '请输入密码', inputType: 'password' },
  {
    label: '传输协议',
    value: '',
    key: 'stream_pto',
    type: 'SelectView',
    options: TRANSPORT_PROTOCAL_OPTIONS,
    placeholder: '请输入视频流类型',
    clearable: true,
  },
]);

export const output = ref([
  [
    { label: 'GA1400', value: false, key: 'ga1400_enable', type: 'SwitchView' },
    { label: '图片传输设备ID', value: '', key: 'ga1400_id', type: 'InputView', clearable: true },
  ],
  [
    { label: 'GB28181', value: false, key: 'gb28181_enable', type: 'SwitchView' },
    { label: '图片传输设备ID', value: '', key: 'gb28181_id', type: 'InputView', clearable: true },
  ],
]);

export const FORM_RULES: Record<string, FormRule[]> = {
  sn: [{ required: true, message: '请输入设备序列号', trigger: 'blur' }],
  dev_name: [{ required: true, message: '请输入设备名称', trigger: 'blur' }],
};
